<template>
    <m-page>
        <m-header></m-header>
        <!-- 转账时间、转出卡号、金额显示 -->
        <!-- 密码输入框 -->
        <!-- 预留手机号码显示 -->
        <!-- 验证码输入框 -->
        <!-- <ynet-msg-code v-model="msgCode" msgTitle="验证码" ref="msgRef" @clickCode="send">
        </ynet-msg-code> -->
        <!-- 协议勾选框 -->
        <!-- 完成按钮 -->
        <!-- <ynet-button @click-native="morrowTransferSubmit">完成</ynet-button> -->

    </m-page>
</template>
<script>
    import { sendSMSCode, prepare, verifySMSCode, signPlan } from '../../request/index';
    export default {
        data() {
            return {};
        },
        computed: {},
        watch: {},
        methods: {
            /**
             * Frame
             * 获取短信验证码
             * TODO
             */
            send() {
                //获取客户号
                app.api
                    .getUserInfo()
                    .then(({ userInfo = {} }) => {
                        console.log(userInfo);
                        //判断客户号是否为空，为空不能获取短信验证码
                        //客户号不为空调用短信验证码接口
                        //接口上送参数
                        let params = {};
                        sendSMSCode(params)
                            .then(res => {
                                console.log(res);
                                //弹框提示短信验证码已发送
                            })
                            .catch(err => {
                                console.log('======send=====');
                                console.log(err);
                            });
                    })
                    .catch(err => {
                        console.log(err);
                        alert('获取用户信息错误');
                    });
            },

            /**
             * Frame
             * 次日转账提交
             * TODO
             */
            morrowTransferSubmit() {
                //1、页面必输项合法性校验
                //2、判断收款账户是否是长沙银行存折和对公账户 ，是给收款银行名称赋值：bankName = "长沙银行";
                //3、调用密码防重接口

                //接口上送参数
                let params = {};
                prepare(params)
                    .then(res => {
                        console.log(res);
                        //获取接口返回的token值，并缓存
                        //校验短信验证码
                        this.verifySMSCode();
                    })
                    .catch(err => {
                        console.log('======morrowTransferSubmit=====');
                        console.log(err);
                    });
            },
            /**
             * Frame
             * 校验短信验证码
             * TODO
             */
            verifySMSCode() {
                //接口上送参数
                let params = {};
                verifySMSCode(params)
                    .then(res => {
                        console.log(res);
                        //调用周期付新增支出接口
                        this.signPlan();
                    })
                    .catch(err => {
                        console.log('======verifySMSCode=====');
                        console.log(err);
                    });
            },
            /**
             * Frame
             * 周期付新增支出接口
             * TODO
             */
            signPlan() {
                //接口上送参数
                let params = {};
                signPlan(params)
                    .then(res => {
                        console.log(res);
                        //成功，跳转至转账结果页面
                    })
                    .catch(err => {
                        console.log('======signPlan=====');
                        console.log(err);
                    });
            }
        },
        mounted() {},
        created() {
            //获取转账相关信息
        }
    };
</script>